﻿using System.Configuration;
using System.Data;
using Microsoft.ApplicationBlocks.Data;

namespace Core.AdminGroup
{
    public class AdminGroupDAL
    {
        private static readonly string Conn = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();

        public static IDataReader AdminGroup_GetAll()
        {
            return SqlHelper.ExecuteReader(Conn, "AdminGroup_GetAll");
        }

        public static IDataReader AdminGroup_GetById(int id)
        {
            return SqlHelper.ExecuteReader(Conn, "AdminGroup_GetById", id);
        }

        public static int AdminGroup_GetMaxPriority()
        {
            return (int)SqlHelper.ExecuteScalar(Conn, "AdminGroup_GetMaxPriority");
        }

        public static int AdminGroup_Create(AdminGroupObject o)
        {
            return (int)SqlHelper.ExecuteScalar(Conn, "AdminGroup_Create", o.Name, o.Description, o.Status, o.Priority);
        }

        public static void AdminGroup_Update(AdminGroupObject o)
        {
            SqlHelper.ExecuteNonQuery(Conn, "AdminGroup_Update", o.AdminGroupId, o.Name, o.Description, o.Status, o.Priority);
        }

        public static void AdminGroup_Delete(int adminGroupid)
        {
            SqlHelper.ExecuteNonQuery(Conn, "AdminGroup_Delete", adminGroupid);
        }
    }
}
